package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.enumclass.ChannelClientType;
import com.rockcent.mall.lib.domain.enumclass.ChannelStatus;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

/**
 * Created by oyhk on 16/7/15.
 */
@Entity
@Table(name = "channel")
@DynamicInsert
@DynamicUpdate
public class Channel extends IDEntityMall {

    @Column(columnDefinition = "varchar(100) comment '名称'")
    private String name;
    @Column(columnDefinition = "bigint comment '类型'")
    private Long channelTypeId;
    @Column(columnDefinition = "varchar(200) comment '流量估计'")
    private String flowEstimation;
    @Column(columnDefinition = "varchar(255) comment '渠道简介'")
    private String intro;
    @Column(columnDefinition = "varchar(1024) comment '渠道描述'")
    private String detail;
    @Column(columnDefinition = "varchar(50) comment '生成编号'")
    private String number;
    @Column(columnDefinition = "varchar(50) comment '渠道码'", unique = true)
    private String salesCode;
    @Column(columnDefinition = "varchar(30) comment '渠道状态'")
    @Enumerated(EnumType.STRING)
    private ChannelStatus channelStatus;
    @Column(columnDefinition = "bit comment '是否默认渠道'")
    private Boolean isSystemDefault = false;
    @Column(columnDefinition = "bigint comment '商户id'")
    private Long merchantId;
    @Column(columnDefinition = "bigint comment '平台id'")
    private Long mallId;
    @Column(columnDefinition = "text comment '图标Url'")
    private String iconUrl;
    @Column(columnDefinition = "varchar(500) comment '二维码Url'")
    private String promoteUrl;
    @Column(columnDefinition = "varchar(100) comment '活动名称'")
    private String activityName;
    @Column(columnDefinition = "varchar (20) default 'NO' comment '小程序标志 (是:YES,否:NO)'")
    @Enumerated(EnumType.STRING)
    private Whether appFlag = Whether.NO;

    @Column(columnDefinition = "varchar (20) default 'NO' comment '小程序默认渠道标志（供线上使用） (是:YES,否:NO)'")
    @Enumerated(EnumType.STRING)
    private Whether appDefault = Whether.NO;

    @Column(columnDefinition = "varchar (30) default 'WXH5' comment '渠道类型'")
    @Enumerated(EnumType.STRING)
    private ChannelClientType channelClientType;

    public static final String ATTR_THIS = "channel";

    public static final long DEFAULT_CHANNEL_TYPE_ID = 14;  //其他渠道, 对应数据库的记录id, channel_type 表
    public static final long DEFAULT_CATEGORY_ID = 80; //其他 , 对应数据库记录id, category 表
    public static final String DEFAULT_SELF_CHANNEL_NUM = "001";  //自有渠道
    public static final String DEFAULT_PLANFORM_CHANNEL_NUM = "002"; //平台渠道
    public static final String DEFAULT_SELF_CHANNEL_NAME = "默认自有渠道";
    public static final String DEFAULT_PLATFORM_CHANNEL_NAME = "默认平台渠道";
    public static final String DEFAULT_MARKET_CHANNEL_NAME = "默认分销渠道";


    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public Boolean getSystemDefault() {
        return isSystemDefault;
    }

    public void setSystemDefault(Boolean systemDefault) {
        isSystemDefault = systemDefault;
    }

    public String getName() {
        return name;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl;
    }

    public String getPromoteUrl() {
        return promoteUrl;
    }

    public void setPromoteUrl(String promoteUrl) {
        this.promoteUrl = promoteUrl;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getChannelTypeId() {
        return channelTypeId;
    }

    public void setChannelTypeId(Long channelTypeId) {
        this.channelTypeId = channelTypeId;
    }

    public String getFlowEstimation() {
        return flowEstimation;
    }

    public void setFlowEstimation(String flowEstimation) {
        this.flowEstimation = flowEstimation;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public ChannelStatus getChannelStatus() {
        return channelStatus;
    }

    public void setChannelStatus(ChannelStatus channelStatus) {
        this.channelStatus = channelStatus;
    }

    public String getSalesCode() {
        return salesCode;
    }

    public void setSalesCode(String salesCode) {
        this.salesCode = salesCode;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public Whether getAppFlag() {
        return appFlag;
    }

    public void setAppFlag(Whether appFlag) {
        this.appFlag = appFlag;
    }

    public Whether getAppDefault() {
        return appDefault;
    }

    public void setAppDefault(Whether appDefault) {
        this.appDefault = appDefault;
    }

    public ChannelClientType getChannelClientType() {
        return channelClientType;
    }

    public void setChannelClientType(ChannelClientType channelClientType) {
        this.channelClientType = channelClientType;
    }

    @Override
    public String toString() {
        return "Channel{" +
                "name='" + name + '\'' +
                ", channelTypeId=" + channelTypeId +
                ", id=" + id +
                ", flowEstimation='" + flowEstimation + '\'' +
                ", dateCreated=" + dateCreated +
                ", intro='" + intro + '\'' +
                ", lastUpdated=" + lastUpdated +
                ", detail='" + detail + '\'' +
                ", number='" + number + '\'' +
                ", isDelete=" + isDelete +
                ", version=" + version +
                ", salesCode='" + salesCode + '\'' +
                ", channelStatus=" + channelStatus +
                ", isSystemDefault=" + isSystemDefault +
                ", merchantId=" + merchantId +
                ", mallId=" + mallId +
                ", iconUrl='" + iconUrl + '\'' +
                ", promoteUrl='" + promoteUrl + '\'' +
                ", activityName='" + activityName + '\'' +
                ", appFlag=" + appFlag +
                ", appDefault=" + appDefault +
                '}';
    }
}
